package lab03.Test13;


import java.sql.*;

/**
 * Created by Administrator on 2017/11/23.
 */
public class Test01 {
    public static void main(String[] args) {
        //加载驱动程序
        Connection connection=null;
        Statement statement=null;
        ResultSet resultSet=null;
        //表名：t_users
        //添加数据
        String sql="insert into t_users (id,username,password) VALUES (1,'www','12436578')";
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection= DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017",
                    "root",
                    "123456"
            );
            statement=connection.createStatement();
            statement.execute(sql);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        finally {
            try {
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }


}
